<style tyle="text/css">
    .modal-lg {
        width: 70%;
    }

    .panel-body {
        padding: 0px;
    }

    .disable{
        background-color: #b1bcb4 !important;
    }

    .form-group {
        margin-bottom: 5px;
    }
</style>
<div class="modal-header">
    <h4 class="modal-title">分销商授权</h4>
</div>
<div class="modal-body clearfix">
    <form name="form" class="form-horizontal ng-pristine ng-valid-required">
        <div class="form-group">
            <label class="col-lg-3 control-label">产品名称:</label>
            <label class="col-lg-4" style=" padding-top: 7px;">{{office.name}}</label>
        </div>
        <div class="form-group">
            <label class="col-lg-3 control-label">价格:</label>
            <label class="col-lg-4" style=" padding-top: 3px;">
                供货价格：
                <strong style="color:red;font-size: 18px;">{{office.cost_price}}</strong>元 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;指导价格：
                <strong style="font-size: 18px;">{{office.guide_price}}</strong>元
            </label>
        </div>
        <div class="form-group">
            <label class="col-lg-3 control-label">公开销售:</label>
            <label class="col-lg-4" style=" padding-top: 7px;">
                {{office.open_company=='0'? '公开': '不公开'}}
            </label>
        </div>
        <div class="form-group" ng-show="office.open_company=='0'">
            <label class="col-lg-3 control-label">公开销售加价:</label>
            <div class="col-lg-3">
                <div class="input-group">
                    <input type="number" class="form-control" ng-model="office.unify_float_price1" ng-change="office.is_edit = true">
                    <span class="input-group-addon">元</span>
                </div>
            </div>
            <label class="col-lg-2 control-label">
                <a class="btn btn-xs btn-success pull-left" ng-show="office.is_edit" ng-click="updateUnfiyPrice()">保存</a>
            </label>
        </div>
    </form>

    <br>
    <div ng-repeat="group in groupList">
        <div class="panel panel-default">
            <div class="panel-heading col-xs-12" style="padding-top: 1px; padding-bottom: 0px;">
                <div class="col-xs-1" ng-show="!group.is_edit" style="padding: 0px;">
                    <h5 ng-click="open_toggle($index)">
                        <span ng-show="!group.is_open" class="glyphicon glyphicon-plus"></span>
                        <span ng-show="group.is_open" class="glyphicon glyphicon-minus"></span>
                        <span>{{group.name}}</span>
                    </h5>
                </div>
                <div class="col-xs-4" ng-show="$index != groupList.length - 1" style="padding: 0px;">
                    <a class="btn btn-xs btn-link mt10" ng-click="change1(group, true, $index)">组内全部允许销售</a>
                    <a class="btn btn-xs btn-link mt10" ng-click="change1(group, false, $index)">组内全部禁售</a>
                </div>
                <div class="col-xs-6" ng-show="group.is_auth && !group.is_edit && group.code != 'weifenzu'" style="padding-top: 4px;">
                    
                    <span style="width: 40%">
                        <span class="pull-left" style="margin-top: 3px">供货价 + &nbsp;</span>
                        <div class="col-xs-4 row">
                                <input type="number" class="form-control" style="height: 25px;" min="0" ng-model="group.floating_price" ng-change="changeAll(group)">
                        </div>
                    </span>
                        <a class="btn btn-xs btn-success pull-right" ng-show="group.updateStatus" ng-click="updateAllPrice($index,group)">批量设置</a>
                    </span>
                </div>
                <div class="col-xs-4" ng-show="group.is_edit">
                    <input type="text" class="form-control" ng-model="temp_update_group.name" placeholder="请输入组名称" />
                </div>
                <div class="col-xs-2 pull-right mt5" ng-show="group.is_edit">
                    <a class="btn btn-xs btn-warning" ng-click="giveUpdate($index)">取消</a>
                </div>
                <div class="col-xs-2 pull-right mt5" ng-show="group.is_edit">
                    <a class="btn btn-xs btn-success" ng-click="save($index)">保存</a>
                </div>
                <div class="col-xs-1 pull-right mt5" ng-show="!group.is_edit && $index != groupList.length - 1">
                    <a class="btn btn-xs btn-info" ng-click="update($index)">编辑</a>
                </div>
            </div>
            <table class="table table-bordered panel-body" ng-show="group.is_open">
                <thead>
                    <tr>
                        <th class="text-center col-xs-2">分销商名称(编号)</th>
                        <th class="text-center col-xs-2">组别</th>
                        <th class="text-center col-xs-1" style="padding-left: 0px; padding-right: 0px;">授权销售</th>
                        <th class="text-center col-xs-6">结算价格(元)</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="obj in group.childList">
                        <td>{{obj.name}}({{obj.code}})</td>
                        <td>
                            <select class="form-control" ng-model="obj.group_code" ng-change="saveGroup(obj, $index, $parent.$index)">
                                <option ng-value="child_group.code" ng-repeat="child_group in group_select_list" ng-show="$index != group_select_list.length - 1">{{child_group.name}}</option>
                            </select>
                        </td>
                        <td style="padding-left: 0px; padding-right: 0px;">
                            <div ng-show="obj.select_type != 2 && office.open_company!='0'">
                                <label class="i-switch bg-success" style="margin-left: 15px;" >
                                    <input  type="checkbox" ng-model="obj.is_purchase" ng-change="change2(obj, obj.is_purchase, $index, $parent.$index)">
                                    <i></i>
                                </label>
                            </div>
                            <div class="text-center" ng-show="obj.select_type != 2 && office.open_company=='0'">
                                {{obj.select_type == '1'? '已采购': '未采购'}}
                            </div>
                            <div class="text-center" ng-show="obj.select_type == 2">禁止销售</div>
                        </td>
                        <td>
                            <div class="input-group" ng-show="obj.is_purchase">
                                <div class="pull-left" style="margin-top: 2px;">
                                    供货价&nbsp;&nbsp;+&nbsp;&nbsp;
                                </div>
                                <div class="pull-left" style="width: 140px;">
                                    <input type="number" class="form-control" style="height: 25px;" ng-if="office.negative" ng-model="obj.floating_price"
                                        ng-change="obj.is_edit = true">
                                    <input type="number" class="form-control" style="height: 25px;" ng-if="!office.negative" ng-model="obj.floating_price"
                                        ng-change="obj.is_edit = true">
                                </div>
                                <div class="pull-left" style="margin-top: 2px;">
                                    元&nbsp;&nbsp;=&nbsp;&nbsp;{{(office.cost_price + obj.floating_price).toFixed(2)}}元&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                </div>
                                <a class="btn btn-xs btn-success pull-right" ng-show="obj.is_edit" ng-click="updatePrice(obj, $index, $parent.$index)">保存</a>
                            </div>
                        </td>
                    </tr>
                    <tr ng-show="!group.childList || group.childList.length < 1">
                        <td colspan="5" class="text-center">没有数据</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <br ng-if="!group.is_open">
        <br ng-if="!group.is_open">
    </div>
    <div class="col-xs-12 mt20">
        <div class="col-xs-4" ng-show="temp_group.isReadly">
            <input type="text" class="form-control" ng-model="temp_group.name" placeholder="请输入组名称" />
        </div>
        <div class="col-xs-2" ng-show="temp_group.isReadly">
            <a class="btn btn-success btn-block" ng-click="create()">保存</a>
        </div>
        <div class="col-xs-2" ng-show="temp_group.isReadly">
            <a class="btn btn-warning btn-block" ng-click="give()">取消</a>
        </div>
        <div class="col-xs-2" ng-show="!temp_group.isReadly">
            <a class="btn btn-success btn-block" ng-click="readly()">新增分组</a>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button class="btn btn-danger" type="button" ng-click="ok()">关闭</button>
</div>